package com.pactera.madp.cp.controller.sidebar;

import com.pactera.madp.common.core.util.R;
import com.pactera.madp.common.log.annotation.SysLog;
import com.pactera.madp.cp.service.FileUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * FileController
 *
 * @author jun
 * @version 1.0
 * 2021/7/8 11:46
 **/
@RequestMapping("/upload")
@RestController()
@Api(value = "upload",tags = "文件上传-侧边栏")
@AllArgsConstructor
public class FileController {

    private final FileUploadService fileUploadService;

    @SysLog("上传图片")
    @PostMapping
    @ApiOperation(value = "上传图片")
    public R uploadFile(MultipartFile file) {
        if (file == null) {
            return R.failed("上传失败，未输入文件");
        }
        return fileUploadService.uploadFile(file);
    }

}
